<template>
  <div class="hello" v-loading="$store.state.isLoading">
    <h1>{{ msg }}</h1>
    <p>{{$store.state.counter}}</p>
    <el-button type="primary" @click="add">counter + 1</el-button>
    <el-button type="primary" @click="asyncAdd">async counter + 1</el-button>
    <p>double：{{$store.getters.doubleCounter}}</p>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  created(){
    console.log(this.$store)
  },
  methods: {
    add() {
      this.$store.commit('SET_ADD')
    },
    asyncAdd(){
      this.$store.dispatch('add')
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
